<?php
require_once(ROOT . LIBRARY .'/fields/common.inc');

class fields_decimal extends fields_common
{
   /**
    * Normalize Value
    *
    * @param integer $value
    */
   public function normalizeValue($value)
   {
      $this->value = $value;
      
      return $this->value;
   }


   /**
    * Get HTML code for integer fields
    *
    * @param object $data
    * @return string
    */
   public function getFieldHTML($data)
   {
      $value = $data->{$this->alias}(null);

      return '<input type="text" name="f['. $this->alias .']" id="f_'. $this->alias .'" value="'. htmlspecialchars($value) .'" />';
   }


   /**
    * Validate Input Data against field type
    *
    * @param mixed $value
    * @param object $objectData
    * @return mixed
    */
   public function validateInput($value, $objectData = NULL)
   {
      if(!$this->isValidNumeric($value))
          $value = NULL;

      $this->value = $value;
      
      return $this->value;
   }
}

